package com.tiantang.study.netty.reactor;

/**
 * @author liujinkun
 * @Title: Server
 * @Description: 启动类
 * @date 2019/5/5 11:47 PM
 */
public class Server {

    private Selector selector = new Selector();

    Dispatcher eventLooper = new Dispatcher(selector);

    private Acceptor acceptor;

    public Server(int port){
        acceptor = new Acceptor(port,selector);
    }

    public void start(){
        eventLooper.registerEventHandler(EventType.ACCEPT,new AcceptEventHandler(selector));
        new Thread(acceptor,"Acceptor-" + acceptor.getPort()).start();
        eventLooper.handleEvents();
    }
}
